package Homework.dayG;

/**
 * 当一个线程调用sleep
 */
public class SleepDemo {
    public static void main(String[] args) {
        Thread jc = new Thread("嘉诚") {
            public void run() {
                System.out.println(getName() + ":肚子饿了去吃口饭");
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    System.out.println(getName() + ":我还没吃完呢哥们!");
                }
                System.out.println("吃完了!走吧");
            }
        };
        Thread cb = new Thread("诚爸") {
            public void run() {
                System.out.println(getName() + ":你吃没吃完?");
                System.out.println(getName() + ":快点吃!");
                for (int i = 0; i < 6; i++) {
                    System.out.println(getName() + ":快吃");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {}
                }
                System.out.println(getName()+":吃快一点好吗?");
                jc.interrupt();
            }
        };
        jc.start();
        cb.start();
    }
}